Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(jest-transform): refactor transformer API to reduce number of arguments #10834

Merged
merged 16 commits into from
Nov 16, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Nov 16, 2020

Summary

Sorta for #10823 (comment). While writing the docs the arguments jumped out to me, so decided to refactor the code.

Test plan

Existing tests should pass, tweaked others

@SimenB SimenB changed the title Refactor transform arguments chore(jest-transform): refactor transformer API to reduce number of arguments Nov 16, 2020
@@ -1,80 +1,98 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ScriptTransformer passes expected transform options to getCacheKey 1`] = `
Object {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Would be lovely to add a CodeTransformations doc link to the "syntax error" detailed message, or change the generic documentation link to this one

"unmockedModulePathPatterns": undefined,
"watchPathIgnorePatterns": Array [],
},
"configString": "{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-jasmine2\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this snapshot and thinking if we need to bust the transform cache when any of the configuration options change? Wouldn't it be sufficient to only reset cache when transform output affecting config is changed, like cache, transform, cacheDirectory, extraGlobals? Downside would be maintaining such a list

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downside would be maintaining such a list

exactly this. Might be worth it, tho

@@ -144,6 +144,7 @@
},
"resolutions": {
"@types/jest/jest-diff": "^25.1.0",
"@types/jest/pretty-format": "^25.1.0"
"@types/jest/pretty-format": "^25.1.0",
"fbjs-scripts": "patch:fbjs-scripts@^1.1.0#./patches/fbjs-scripts.patch"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/CodeTransformation.md Outdated Show resolved Hide resolved
@SimenB
Copy link
Member Author

SimenB commented Nov 16, 2020

change the generic documentation link to this one

which docs?

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants